<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="https://www.purecss.cn/css/pure-min.css">
    <link rel="stylesheet" href="https://www.purecss.cn/css/main-grid.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.1.min.js"></script>

</head>
<body>
<div id="mse"></div>
<script src="http://cdn.jsdelivr.net/npm/xgplayer/browser/index.js" charset="utf-8"></script>
<script src="http://cdn.jsdelivr.net/npm/xgplayer-hls.js/browser/index.js" charset="utf-8"></script>
<script>
    window.addEventListener('resize',function(){
        document.getElementById('mse').style.height=window.innerHeight+'px';
        document.getElementById('mse').style.width=window.innerWidth-20+'px';
    });

    var player = undefined
    $(document).ready(function(){
        (function ($) {
            $.getUrlParam = function (name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]); return null;
            }
        })(jQuery);

        var purl = $.getUrlParam('purl');
        if (purl == null) {
            alert("no purl param")
            return
        }

        // http://json.hulanap.com/home/api?type=ys&uid=271611&key=blnpuxABCEIMNQ0289&url=https://www.iqiyi.com/v_19rrdnxtyk.html
        $.get('/play.php?purl=' + purl, function(data) {
            data = JSON.parse(data)
            if (data.url.indexOf(".m3u8")>0) {
                player = new HlsJsPlayer({
                    "id": "mse",
                    "playsinline": true,
                    "width": window.innerWidth-20,
                    "height": window.innerHeight,
                    url:data.url,
                    autoplay: false,
                    cors: true,
                    "playbackRate": [
                        0.1,
                        1,
                        1.5,
                        2
                    ]
                });
            }else if (data.url.indexOf(".mp4")>0){
                player = new Player({
                    "id": "mse",
                    "playsinline": true,
                    "width": window.innerWidth-20,
                    "height": window.innerHeight,
                    url:data.url,
                    autoplay: false,
                    cors: true,
                    "playbackRate": [
                        0.1,
                        1,
                        1.5,
                        2
                    ]
                })
            }else {
                alert("unknow format " + data.url)
                player = new Player({
                    "id": "mse",
                    "playsinline": true,
                    "width": window.innerWidth-20,
                    "height": window.innerHeight,
                    url:data.url,
                    autoplay: false,
                    "playbackRate": [
                        0.1,
                        1,
                        1.5,
                        2
                    ]
                });
            }

        });

        //
        // player.start(vurl)
        // alert("1")
        // player.reload()
        // alert("2")
        // player.play()
    });

    function start_play(){
        player.pause()
        player.src = vurl2
        player.reload()
        player.play()
    }

</script>
</body>
</html>
